# -*- coding: utf-8 -*-
# @version : 1.0
# @File    : token_getter.py
# @Date    : 2024/9/25 09:28
# @Author  : GlenZhao
# @Desc    :

from typing import Annotated
from fastapi import Header, HTTPException, status

def get_bearer_token(authorization: Annotated[str, Header()] = ""):
    if not authorization.startswith("Bearer "):
        raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid Authorization header")

    _, token = authorization.split()
    return token